<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\SpecificationTemplate;
use App\Models\Category;

class SpecificationTemplateSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        // 获取分类
        $iphoneCategory = Category::where('slug', 'orange-phone')->first();

        $templates = [
            // Orange Phone 完整规格模板（简化版）
            [
                'name' => 'Orange Phone 完整规格模板',
                'slug' => 'orange-phone-complete-specs',
                'description' => 'Orange Phone 系列产品的完整规格模板，包含颜色和存储容量',
                'category_id' => $iphoneCategory?->id,
                'attributes_config' => [
                    [
                        'name' => '颜色',
                        'slug' => 'color',
                        'type' => 'color',
                        'options' => [
                            ['name' => '深空黑色', 'value' => 'space-black', 'color_code' => '#1C1C1E'],
                            ['name' => '银色', 'value' => 'silver', 'color_code' => '#F2F2F7'],
                            ['name' => '自然钛色', 'value' => 'natural-titanium', 'color_code' => '#C0C0C0'],
                            ['name' => '蓝色钛色', 'value' => 'blue-titanium', 'color_code' => '#4169E1'],
                        ],
                        'is_required' => true,
                        'is_variant' => true,
                    ],
                    [
                        'name' => '存储容量',
                        'slug' => 'storage',
                        'type' => 'select',
                        'options' => [
                            ['name' => '128GB', 'value' => '128gb'],
                            ['name' => '256GB', 'value' => '256gb'],
                            ['name' => '512GB', 'value' => '512gb'],
                            ['name' => '1TB', 'value' => '1tb'],
                        ],
                        'is_required' => true,
                        'is_variant' => true,
                    ]
                ],
                'is_active' => true,
                'is_default' => true,
                'sort_order' => 100,
            ],
        ];

        foreach ($templates as $template) {
            SpecificationTemplate::create($template);
        }

        $this->command->info('✅ 创建了 1 个规格模板');
    }
}
